<?php

namespace App\Http\Controllers\Api\Rbac;

use App\Http\Controllers\Controller;
use App\Rep\Rbac\NodeRep;
use Illuminate\Http\Request;

class Node extends Controller
{
    protected $rep;

    public function __construct(Request $request)
    {
        $this->rep = new NodeRep();
    }

    //获取权限列表
    public function getNodeList(Request $request){
        $params = $request->all();
        $data = $this->rep->getNodeListRep($params);
        return re(0,$data,'success');
    }
    //添加权限
    public function createNode(Request $request){
        $params = $request->all();
        $data = $this->rep->createNodeRep($params);
        return re(0,$data,'success');
    }
    //删除权限
    public function delNode(Request $request){
        $params = $request->only(['id','is_del']);
        $data = $this->rep->delNodeRep($params);
        return re(0,$data,'success');
    }

    //菜单栏
    public function getMenu(Request $request){
        //p($request->all());
        $role_id = $request->role_id;
        $list = $this->rep->getMenuRep($role_id);
        return re(0,$list,'success');
    }

    //获取菜单及按钮
    public function getMenuAndButton(Request $request){
        $role_id = $request->role_id;
        $list = $this->rep->getMenuAndButtonRep($role_id);
        return re(0,$list,'success');
    }
}
